﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Xml;

namespace ShenRuQianChuChapt6Binding
{
    /// <summary>
    /// chapt6_3_9UseXMLDataAsTheSourceOfBinding.xaml 的交互逻辑
    /// </summary>
    public partial class chapt6_3_9UseXMLDataAsTheSourceOfBinding : Window
    {
        public chapt6_3_9UseXMLDataAsTheSourceOfBinding()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(@"RawData.xml");

            //XmlDataProvider xdp = new XmlDataProvider();
            //xdp.Document = doc;

            ////使用Xpath选择需要暴露的数据
            ////现在是需要暴露一组Student
            //xdp.XPath = @"/StudentList/Student";

            //this.listViewStudents.DataContext = xdp;
            //this.listViewStudents.SetBinding(ListView.ItemsSourceProperty, new Binding());



            XmlDataProvider xdp = new XmlDataProvider();
            xdp.Source = new Uri(@"C:\Users\Administrator\source\repos\csharpcore7\ShenRuQianChuChapt6Binding\bin\Debug\RawData.xml");
            xdp.XPath = @"/StudentList/Student";

            this.listViewStudents.DataContext = xdp;
            this.listViewStudents.SetBinding(ListView.ItemsSourceProperty, new Binding());
        }
    }
}
